#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <cmath>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <climits>
#include <vector>
#define int long long
#define x first 
#define y second 
using namespace std;
const int N = 1e5 + 10;
typedef pair<string,int> PII;
PII p[N]; 
bool cmp(const PII &a,const PII &b)
{
    if(a.y != b.y) return (a.y > b.y);
    else return a.x < b.x;
}
void solve()
{
    map<string,int> mp;
    string str;
    while(cin >> str)   
    {
        mp[str]++;
    }
   // for(auto &c : mp) cout << c.x << " " << c.y << endl;
   int i = 0;
   for(auto &c : mp)
   {
       if(c.y >= 3)
       p[i++] = {c.x,c.y};      
   }
   sort(p , p + i ,cmp);
   for(int j = 0; j < i; j++) cout << p[j].x << endl;

}
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr),cout.tie(nullptr);
    int t = 1;
    while(t -- ) solve();
    return 0;
} 
 